home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / UPC12BS1.ZIP / LIB / STATER.C < prev    next >
C/C++ Source or Header  |  1993-07-20  |  4KB  |  86 lines

  1. /*--------------------------------------------------------------------*/
  2. /*    s t a t e r . c                                                 */
  3. /*                                                                    */
  4. /*    File time and size routines                                     */
  5. /*--------------------------------------------------------------------*/
  6.  
  7. /*--------------------------------------------------------------------*/
  8. /*    Changes Copyright (c) 1989-1993 by Kendra Electronic            */
  9. /*    Wonderworks.                                                    */
  10. /*                                                                    */
  11. /*    All rights reserved except those explicitly granted by the      */
  12. /*    UUPC/extended license agreement.                                */
  13. /*--------------------------------------------------------------------*/
  14.  
  15. /*--------------------------------------------------------------------*/
  16. /*                          RCS Information                           */
  17. /*--------------------------------------------------------------------*/
  18.  
  19. /*
  20.  *    $Id: stater.c 1.2 1993/07/20 21:45:37 ahd Exp $
  21.  *
  22.  *    Revision history:
  23.  *    $Log: stater.c $
  24.  *     Revision 1.2  1993/07/20  21:45:37  ahd
  25.  *     Report last modified time, not created time, per Kae Uwe Rommel
  26.  *
  27.  */
  28.  
  29. /*--------------------------------------------------------------------*/
  30. /*                   Standard library include files                   */
  31. /*--------------------------------------------------------------------*/
  32.  
  33. #include <stdio.h>
  34. #include <time.h>
  35. #include <sys/types.h>
  36. #include <fcntl.h>
  37. #include <sys/stat.h>
  38.  
  39. /*--------------------------------------------------------------------*/
  40. /*                    UUPC/extended include files                     */
  41. /*--------------------------------------------------------------------*/
  42.  
  43. #include "lib.h"
  44.  
  45. /*--------------------------------------------------------------------*/
  46. /*                      Define current file name                      */
  47. /*--------------------------------------------------------------------*/
  48.  
  49. currentfile();
  50.  
  51. /*--------------------------------------------------------------------*/
  52. /*    s t a t e r                                                     */
  53. /*                                                                    */
  54. /*    Report date and size of a file                                  */
  55. /*--------------------------------------------------------------------*/
  56.  
  57. time_t stater(const char *file, long *size)
  58. {
  59.    struct stat statbuf;
  60.  
  61. /*--------------------------------------------------------------------*/
  62. /*   If the file doesn't exist, give a nasty message to the caller    */
  63. /*--------------------------------------------------------------------*/
  64.  
  65.    if(stat((char *) file, &statbuf) < 0 )
  66.    {
  67.       printmsg(0,"cannot stat %s",file);
  68.       printerr( file );
  69.       if ( size != NULL )
  70.          *size = 0;
  71.       return -1;              /* Flag file as missing          */
  72.    }
  73.  
  74. /*--------------------------------------------------------------------*/
  75. /*          We have the information; return it to the caller          */
  76. /*--------------------------------------------------------------------*/
  77.  
  78.    if ( size != NULL )
  79.       *size = statbuf.st_size;
  80.  
  81.    printmsg(5,"stater: \"%s\" is %ld bytes; updated %s",
  82.          file, *size, ctime( &statbuf.st_mtime));
  83.    return(statbuf.st_mtime);
  84.  
  85. } /* stater */
  86.